下列多少种排序算法用了分治法?
拓扑排序
▁▁▁▁▁ 是下面 AOV 网的一个拓扑序列。

KMP算法下,长为n的字符串匹配长度为m的字串的时间复杂度为
设主串 T = abaabaabcabaabc,模式串 S = abaabc,采用 KMP 算法进行模式匹配,到匹配成功时为止,在匹配过程中进行的单个字符间的比较次数是:
KMP算法。
#include<cstring>
#include<iostream>
using namespace std;
#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef int Status;
#define MAXSTRLEN 255
void get_nextval(char T[], int nextval[])
{
int i = 1, j = 0;
nextval[1] = 0;
while (i < T[0])
if (j == 0 || T[i] == T[j])
{
++i;
++j;
if (T[i] != T[j])
nextval[i] = j;
else
nextval[i] = nextval[j];
} else
j = nextval[j];
}
int Index_KMP(char S[], char T[], int pos, int next[])
{
int i = pos, j = 1;
while (i <= S[0] && j <= T[0])
if (20分)
{
++i;
++j;
}
else
20分;
if (j > T[0])
20分;
else
return 0;
}
int main()
{
char S[MAXSTRLEN+1],T[MAXSTRLEN+1];
char S1[MAXSTRLEN],S2[MAXSTRLEN];
cin >> S1 >> S2;
strcpy(&S[1],S1);
strcpy(&T[1],S2);
S[0]=strlen(S1);
T[0]=strlen(S2);
int *p = new int[T[0]+1];
get_nextval(T,p);
cout<<Index_KMP(S,T,1,p);
return 0;
}